package com.fourforfo.fourmall.seckill.feign;

import com.fourforfo.common.utils.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @program: xxl-sso-core
 * @description:
 * @author: fourforfo
 * @email: fourforfo@gmail.com
 * @create: 2022-09-14 13:49
 **/
@FeignClient(value = "fourmall-coupon",fallback = CouponFeignServiceFallback.class,configuration = FeignConfiguration.class)
public interface CouponFeignService {

    @ResponseBody
    @GetMapping("/coupon/seckillsession/latest3DaySession")
    R getLatest3DaysSession();

}

class FeignConfiguration {
    @Bean
    public CouponFeignServiceFallback echoServiceFallback() {
        return new CouponFeignServiceFallback();
    }
}

class CouponFeignServiceFallback implements CouponFeignService {

    @Override
    public R getLatest3DaysSession() {
        return R.error("getLatest3DaysSesion远程服务调用失败!");
    }
}
